package com.hxd.mall.utils.open

import android.text.TextUtils
import android.view.Gravity
import android.view.LayoutInflater
import android.widget.TextView
import android.widget.Toast
import com.hxd.mall.R
import com.hxd.mall.constant.HxdGlobalInfo

/**
 * @Function:Toast工具类
 */
object ToastUtil {

    private val toast = Toast.makeText(HxdGlobalInfo.instance, "", Toast.LENGTH_SHORT)

    fun showToast(message: String = "") {
        if (TextUtils.isEmpty(message)) {
            return
        }
        val view = LayoutInflater.from(HxdGlobalInfo.instance).inflate(R.layout.toast, null)
        view.findViewById<TextView>(R.id.tv_toast_message).text = message
        toast.view = view
        toast.setGravity(Gravity.CENTER, 0, 0)
        toast.show()
    }

}
